<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateProductsTable extends Migration
{
    /**
     * Run the migrations.
     *商品表
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('category_id')->index()->comment('商品的分类id');
            $table->unsignedInteger('store_id')->index()->comment('店铺的id');
            $table->string('title')->comment('商品名称');
            $table->string('introduce')->comment('商品的简介');
            $table->text('description')->comment('商品的详情');
            $table->string('image')->comment('展示图片');
            $table->boolean('on_sale')->default(true)->comment('是否售卖');
            $table->unsignedInteger('sold_count')->default(0)->comment('商品的销量');
            $table->unsignedInteger('review_count')->default(0)->comment('评论的数量');
            $table->decimal('price',10,2)->comment('商品的最低价格');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('products');
    }
}
